import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @Author: zhenzhong.wang
 * @Time: 2018/4/3 12:01
 */
public class LunchLocationGenerator {

  List locations = new ArrayList<Object[]>();

  {
    locations.add(new Object[]{"Gala", 2});
    locations.add(new Object[]{"紫瑶楼", 2});
    locations.add(new Object[]{"玛格罗妮", 2});
    locations.add(new Object[]{"牛dong咖喱", 2});
    locations.add(new Object[]{"瓦锅饭", 2});
    locations.add(new Object[]{"家有好面", 2});
    locations.add(new Object[]{"煲仔饭", 2});
    locations.add(new Object[]{"小杨生煎", 2});
  }

  @Test
  public void choose() {

    int[] weights = new int[locations.size()];

    for (int i = 0; i < 1000; i++) {
      int random = new Random().nextInt(locations.size());
      Object[] location = (Object[]) locations.get(random);
      weights[random] += Integer.valueOf(location[1].toString());
    }

    for (int i = 0; i < locations.size(); i++) {
      Object[] result = (Object[]) locations.get(i);
      System.out.println(result[0] + ": " + weights[i]);
    }
  }
}
